﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PdfSharp.Fonts;

namespace Zero.UControl.Demo.Helper
{
    public class MyFontResolver : IFontResolver
    {
        private static readonly byte[] yaheiFontData = File.ReadAllBytes("Resources/Fonts/MSYH.ttf");

        public string DefaultFontName => "Microsoft YaHei";

        public byte[] GetFont(string faceName)
        {
            // 这里只做示例，如果你有多个字体，可以按名称区分
            return yaheiFontData;
        }

        public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
        {
            if (familyName.Equals("Microsoft YaHei", StringComparison.OrdinalIgnoreCase))
            {
                return new FontResolverInfo("Microsoft YaHei");
            }

            // 默认回退
            return PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic);
        }
    }
}
